<template>
	<view class="datails">
<!--    如果通知标题不为空的话-->
		<view v-if="noticeList.notice_leveltype_name!=null">
			<view class="water_Id">
				<view class="water_txt">
					{{noticeList.notice_leveltype_name}}
				</view>
				<view class="tive" v-if="noticeList.state == '有效期内'">
					有效
				</view>
				<view class="tive" v-else-if="noticeList.state == '已失效'">
					失效
				</view>
				<view class="tive" v-else>
					待发
				</view>
			</view>
			<view class="time">
				<view class="time_Fa">
					发布人：{{noticeList.user_name}}
				</view>
				<view class="time_shi">
					发布时间：{{noticeList.begin_time}}
				</view>
			</view>
			<view class="center_in">
				<view class="honorific">
					<view>尊敬的{{user_name}}，您好</view>
					<view>
						<view class="center_text" style="margin-left: 38px;">
							<rich-text :nodes="noticeList.notice_content"></rich-text>
						</view>
						<view v-if="noticeList.notice_image!=''" class="center_Img">
							<view class="Img_item" v-for="(item,index) in img">
								<image class="Img_itemL"
								@click="imageBig(item)"
									:src="item"
									mode="">
								</image>
							</view>
						</view>
					</view>
					<view class="browse">
						浏览：{{noticeList.notice_readnumber}}
					</view>
				</view>
			</view>
		</view>
		
		<view v-if="platform">	
		<view class="water_Id">
			<view class="water_txt">
				{{platform.name}}
			</view>
			<view class="tive" >
				有效
			</view>
		
		</view>
		<view class="time">
			<view class="time_Fa">
				发布单位：{{platform.publisher}}
			</view>
			<view class="time_shi">
				发布时间：{{platform.begin_time}}
			</view>
		</view>
		<view class="center_in">
			<view class="honorific">
				<view>尊敬的{{user_name}}，您好</view>
				<view>
					<!-- <view class="center_text" style="margin-left: 38px;">
						<rich-text :nodes="platform.text"></rich-text>
					</view> -->
					<view v-html="platform.text">
						
					</view>
					
				</view>
				<view class="browse">
					浏览：{{platform.read_total}}
				</view>
			</view>
		</view>
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				platform:{},
				userObj:{},
				noticeList: {},
				user_name: null,
				user_sex: null,
				img:[],
				id:null,
			}
		},
		onLoad(options) {
			this.user_name = uni.getStorageSync('rawData').userName;
			this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
			if(options.id){
				this.id = options.id
				console.log(this.id)
				this.getNewNotice();
			}else{
				console.log('sadasd')
				var obj = JSON.parse(options.val)
				
				this.platform=obj
				this.addReadRecord();
			}
			
			
			
			
		},
		onShow() {
			
		},
		mounted() {
			
		},
		methods: {
			//添加平台公告查看记录
			addReadRecord(){
				this.$request.api.addPtNoticeSeechant({
					user_id:uni.getStorageSync('rawData').userId,
					id:this.platform.id,
					
				}).then(res => {
					
				})
				
			},
			imageBig(url){
				uni.previewImage({
					urls: [url], //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了
				})
			},
			async getNewNotice() {
				// NoticeDetail
				let res = await this.$request.api.NoticeDetail({
					id:this.id,
					notice_type:'业主端',//查询类型    助业网，员工端 业主端
					// pageIndex: 1,
					room_id:this.homelist.roomId,
					user_id: uni.getStorageSync('rawData').userId,
				});
					this.noticeList = res.data.data;
					this.img = this.noticeList.notice_image.split("@")
      },

		}
	}
</script>

<style lang="scss">
	.datails {
		padding: 30rpx;
		background-color: #FFFFFF;

		.water_Id {
			min-height: 80rpx;
			margin-top: 30rpx;
			height: 130rpx;

			.water_txt {
				font-size: 46rpx;
				font-weight: 600;
				float: left;
				line-height: 100rpx;
			}

			.tive {
				float: right;
				text-align: center;
				color: #FFFFFF;
				background-color: #46D345;
				font-size: 14px;
				border-radius: 5px;
				padding: 3px 12px;
				margin-top: 13px;
			}
		}

		.time {
			line-height: 80rpx;
			color: #B2B2B2;
			font-size: 30rpx;

			.time_Fa {
				// width: 30%;
				// float: left;
			}

			.time_shi {
				// width: 70%;
				// float: left;
			}
		}

		.center_in {
			width: 100%;
			font-size: 38rpx;
			padding-top: 80rpx 20rpx 0 0;
			color: #454545;

			.honorific {
				display: inline-block;
				line-height: 80rpx;
				width: 370px;
			}

			.center_text {
				line-height: 50rpx;
				letter-spacing: 3rpx;
			}
      .center_text2 {
        line-height: 50rpx;
        letter-spacing: 3rpx;
        font-size: 13px;
      }


      .center_Img {
				width: 100%;
				height: 212.2rpx;
				display: flex;

				.Img_item {
					// flex: 1;
					width: 215rpx;
					height: 212.5rpx;
					margin: 30rpx 10rpx;

					.Img_itemL {
						width: 100%;
						height: 100%;
						border-radius: 10rpx;
					}
				}
			}

			.browse {
				height: 50rpx;
				font-size: 30rpx;
				padding: 10rpx 30rpx;
				color: #999999;
				padding-top: 80rpx;
			}
		}
	}
</style>
